Using Geopandas (make sure to install the separate requirements file)


In [9]:
import geopandas as gpd

%matplotlib inline

import matplotlib
import numpy as np
import matplotlib.pyplot as plt

In [11]:
dc_boundary = gpd.read_file('../data/dc-boundary.geojson')
dc_boundary.plot()


Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x10e590c18>

In [14]:
dc_quadrants = gpd.read_file('../data/dc-quadrants.geojson')
dc_quadrants.plot()


Out[14]:
<matplotlib.axes._subplots.AxesSubplot at 0x10e92ea58>

In [18]:
last_30_days = gpd.read_file('../data/parking-enforcement-last-30-days.geojson')
last_30_days.plot()


Out[18]:
<matplotlib.axes._subplots.AxesSubplot at 0x10ed31748>

In [20]:
violations_with_quadrants = gpd.sjoin(last_30_days, dc_quadrants, how="inner", op='intersects')

In [22]:
violations_with_quadrants.head()


Out[22]:
ADDDATE CITY INSPECTIONDATE INSPECTIONFLAG INSPECTORNAME LATITUDE LONGITUDE MARADDRESSREPOSITORYID OBJECTID_left ORGANIZATIONACRONYM ... XCOORD YCOORD ZIPCODE geometry index_right NAME OBJECTID_right QUADRANT SHAPE_Area SHAPE_Length
0 2016-06-30T17:03:59 WASHINGTON None N None 38.898106 -76.998665 3495.0 1 DPW ... 400115.83 136695.02 20002 POINT (-76.9986670079 38.8981134889) 2 Northeast 3 NE 4.017519e+07 30312.733391
1 2016-06-30T17:04:30 WASHINGTON None N None 38.897940 -76.998214 4008.0 2 DPW ... 400154.90 136676.58 20002 POINT (-76.9982166174 38.8979473687) 2 Northeast 3 NE 4.017519e+07 30312.733391
2 2016-06-30T17:00:40 WASHINGTON None N None 38.898718 -76.999709 1211.0 3 DPW ... 400025.24 136762.92 20002 POINT (-76.99971131700001 38.898725164) 2 Northeast 3 NE 4.017519e+07 30312.733391
3 2016-06-30T17:02:28 WASHINGTON None N None 38.898772 -76.998642 1181.0 4 DPW ... 400117.81 136768.91 20002 POINT (-76.99864417000001 38.8987791166) 2 Northeast 3 NE 4.017519e+07 30312.733391
14 2016-07-05T12:45:59 WASHINGTON None N None 38.919496 -76.982295 50459.0 15 DPW ... 401535.40 139069.64 20018 POINT (-76.982297053 38.9195035543) 2 Northeast 3 NE 4.017519e+07 30312.733391

5 rows × 34 columns


In [25]:


In [26]:
base = dc_quadrants.plot(color='white')
last_30_days.plot(ax=base, marker='o', color='red', markersize=5)


Out[26]:
<matplotlib.axes._subplots.AxesSubplot at 0x115b50da0>

In [ ]: